﻿//********************************************************************************//
//创建日期：<创建日期，2010-08-02>
//创建作者：<王一飞，wangyifei@shanghai3h.com>
//功能说明：WTB_YIHUDRKXX实体层次
//********************************************************************************//
#region Entity
namespace Entity{
	using System;
	using System.Xml;
	[Serializable()]
	public class WTB_YIHUDRKXX{

		private int m_dec_id;
		/// <summary>
		/// ID自增长，禁止关联
		/// </summary>
		public int ID{get{return m_dec_id;}set{m_dec_id=value;}}

		private string m_str_s_zhubiaobh;
		/// <summary>
		/// 主表编号
		/// </summary>
		public string S_ZHUBIAOBH{get{return m_str_s_zhubiaobh;}set{m_str_s_zhubiaobh=value;}}

		private string m_str_incident_id;
		/// <summary>
		/// 申请单唯一ID
		/// </summary>
		public string INCIDENT_ID{get{return m_str_incident_id;}set{m_str_incident_id=value;}}

		private string m_str_contact_num;
		/// <summary>
		/// 联系人电话
		/// </summary>
		public string CONTACT_NUM{get{return m_str_contact_num;}set{m_str_contact_num=value;}}

		private string m_str_req_type;
		/// <summary>
		/// 办理类型 01-新办；02-续办；03-中止; 04-中止
		/// </summary>
		public string REQ_TYPE{get{return m_str_req_type;}set{m_str_req_type=value;}}

		private string m_str_company;
		/// <summary>
		/// 水务公司
		/// </summary>
		public string COMPANY{get{return m_str_company;}set{m_str_company=value;}}

		private string m_str_settle_method;
		/// <summary>
		/// 优惠方式
		/// </summary>
		public string SETTLE_METHOD{get{return m_str_settle_method;}set{m_str_settle_method=value;}}

		private string m_str_ywyhdz;
		/// <summary>
		/// 业务优惠地址
		/// </summary>
		public string YWYHDZ{get{return m_str_ywyhdz;}set{m_str_ywyhdz=value;}}

		private string m_str_include_applicant;
		/// <summary>
		/// 申请人是否受益
		/// </summary>
		public string INCLUDE_APPLICANT{get{return m_str_include_applicant;}set{m_str_include_applicant=value;}}

		private string m_str_people_num;
		/// <summary>
		/// 受益人人数
		/// </summary>
		public string PEOPLE_NUM{get{return m_str_people_num;}set{m_str_people_num=value;}}

		private string m_str_oper_type;
		/// <summary>
		/// 办件类型 01- 即办件；02- 流转件
		/// </summary>
		public string OPER_TYPE{get{return m_str_oper_type;}set{m_str_oper_type=value;}}

		private string m_str_email;
		/// <summary>
		/// 
		/// </summary>
		public string EMAIL{get{return m_str_email;}set{m_str_email=value;}}

		private string m_str_app_type;
		/// <summary>
		/// 申请方式 01-房产证；02-户口本
		/// </summary>
		public string APP_TYPE{get{return m_str_app_type;}set{m_str_app_type=value;}}

		private string m_str_address_check;
		/// <summary>
		/// 地址校验结果 01-	地址校验一致  02-	地址校验不一致

		/// </summary>
		public string ADDRESS_CHECK{get{return m_str_address_check;}set{m_str_address_check=value;}}
		public WTB_YIHUDRKXX()
		{
		}
}}
#endregion
#region EntityProcess
namespace Access.BLL
{
	using System;
	using System.Data;
	//using System.Data.OracleClient;
	using Entity;
	using System.Configuration;
	using System.Data.Common;
	using Platform.Data;
	using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
    using Oracle.DataAccess;
	public class WTB_YIHUDRKXXProcess{
    	#region Field
		protected string conn;
		#endregion
		#region Construction
        public WTB_YIHUDRKXXProcess(){conn = Platform.Configuration.ConfigHelper.BusinessConnString;}
		#endregion
		#region public
		
		/// <summary>
        /// 根据WTB_YIHUDRKXX实体添加或者修改WTB_YIHUDRKXX信息
        /// </summary>
		public bool InsertOrUpdate(WTB_YIHUDRKXX WTB_YIHUDRKXX,OracleTransaction Transaction){
			if (WTB_YIHUDRKXX.ID == 0)
            {
                InsertWTB_YIHUDRKXX(WTB_YIHUDRKXX, Transaction);
            }
            else
            {
                UpdateWTB_YIHUDRKXX(WTB_YIHUDRKXX, Transaction);
            }
            return WTB_YIHUDRKXX.ID == 0 ? false : true;
        }
		
		/// <summary>
        /// 根据WTB_YIHUDRKXX实体添加或修改WTB_YIHUDRKXX信息
        /// </summary>
		public bool InsertOrUpdate(WTB_YIHUDRKXX WTB_YIHUDRKXX){
			return InsertOrUpdate(WTB_YIHUDRKXX,null);
        }
	
		
		
		/// <summary>
        /// 根据WTB_YIHUDRKXX主键删除WTB_YIHUDRKXX信息
        /// </summary>
		/// <param name="ID"></param>
		public bool DeleteWTB_YIHUDRKXX(int ID,OracleTransaction Transaction)
        {
            string spName = "CS_DelWTB_YIHUDRKXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
			storedParams[0].Value = ID;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result==0?false:true;
        }
		
		/// <summary>
        /// 根据WTB_YIHUDRKXX主键删除WTB_YIHUDRKXX信息
        /// </summary>
		/// <param name="ID"></param>
		public bool DeleteWTB_YIHUDRKXX(int ID)
        {
           	return DeleteWTB_YIHUDRKXX(ID,null);
        }
		
		/// <summary>
        /// 根据条件删除WTB_YIHUDRKXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
		public bool DeleteWTB_YIHUDRKXXesDynamic(string WhereClause, OracleTransaction Transaction)
        {
            string spName = "CS_DelWTB_YIHUDRKXXesDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = WhereClause;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }
		
		/// <summary>
        /// 根据条件删除WTB_YIHUDRKXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
		public bool DeleteWTB_YIHUDRKXXesDynamic(string WhereClause)
        {
           return DeleteWTB_YIHUDRKXXesDynamic(WhereClause,null);
        }
		
		/// <summary>
        /// 根据WTB_YIHUDRKXX主键选择WTB_YIHUDRKXX信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>WTB_YIHUDRKXX信息</returns>
		public WTB_YIHUDRKXX SelectWTB_YIHUDRKXX(int ID,OracleTransaction Transaction)
        {
            string spName = "CS_SelWTB_YIHUDRKXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
			storedParams[0].Value = ID;
            OracleDataReader rd;
            if (Transaction == null)
                rd = OracleHelper.ExecuteReader(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                rd = OracleHelper.ExecuteReader((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (rd.Read())
            {
                WTB_YIHUDRKXX WTB_YIHUDRKXX = PopulateWTB_YIHUDRKXX(rd);
                rd.Close();
				return WTB_YIHUDRKXX;
            }
            else
                return null;
        }
		
		/// <summary>
        /// 根据WTB_YIHUDRKXX主键选择WTB_YIHUDRKXX信息
        /// </summary>
        /// <returns>WTB_YIHUDRKXX信息</returns>
		public WTB_YIHUDRKXX SelectWTB_YIHUDRKXX(int ID)
        {
			return SelectWTB_YIHUDRKXX(ID,null);       
        }
		
		/// <summary>
        /// 选择所有WTB_YIHUDRKXX信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>所有WTB_YIHUDRKXX信息</returns>
		public DataTable SelectWTB_YIHUDRKXXesAll(OracleTransaction Transaction)
        {
            string spName = "CS_SelWTB_YIHUDRKXXesAll";
			OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds=null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName,storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName,storedParams);
			if(ds!=null&&ds.Tables.Count>0){
				AddRowNumber(ds.Tables[0]);
				return ds.Tables[0];
			}
			else
				return null;
        }
		
		/// <summary>
        /// 选择所有WTB_YIHUDRKXX信息
        /// </summary>
        /// <returns>所有WTB_YIHUDRKXX信息</returns>
		public DataTable SelectWTB_YIHUDRKXXesAll()
        {
            return SelectWTB_YIHUDRKXXesAll(null);
        }
		
		/// <summary>
        /// 根据条件选择WTB_YIHUDRKXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>WTB_YIHUDRKXX信息</returns>
		public DataTable SelectWTB_YIHUDRKXXesDynamic(string WhereClause, string OrderByExpression, OracleTransaction Transaction)
        {
            string spName = "CS_SelWTB_YIHUDRKXXesDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value =string.IsNullOrEmpty(WhereClause.Trim())?"1=1":WhereClause;
            storedParams[1].Value = OrderByExpression;
            DataSet ds=null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName,storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName,storedParams);
			if(ds!=null&&ds.Tables.Count>0){
				AddRowNumber(ds.Tables[0]);
				return ds.Tables[0];
			}
			else
				return null;
        }		
		
		
		/// <summary>
        /// 根据条件选择WTB_YIHUDRKXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <returns>WTB_YIHUDRKXX信息</returns>
		public DataTable SelectWTB_YIHUDRKXXesDynamic(string WhereClause, string OrderByExpression)
        {
            return SelectWTB_YIHUDRKXXesDynamic(WhereClause, OrderByExpression,null);
        }		
		
		
		
		/// <summary>
        /// 根据条件选择WTB_YIHUDRKXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
		/// <param name="PageIndex">页码</param>
		/// <param name="PageSize">页数</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>WTB_YIHUDRKXX信息</returns>
		public DataTable SelectWTB_YIHUDRKXXesDynamic(string WhereClause, string OrderByExpression, int PageIndex,int PageSize,OracleTransaction Transaction)
        {
            string spName = "CS_SelWTB_YIHUDRKXXesDynPaged";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value =string.IsNullOrEmpty(WhereClause.Trim())?"1=1":WhereClause;
            storedParams[1].Value = OrderByExpression;
			storedParams[2].Value = PageIndex;
			storedParams[3].Value = PageSize;
            DataSet ds=null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName,storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName,storedParams);
			if(ds!=null&&ds.Tables.Count>0){
				AddRowNumber(ds.Tables[0]);
				return ds.Tables[0];
			}
			else
				return null;
        }		
		
		
		/// <summary>
        /// 根据条件选择WTB_YIHUDRKXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
		/// <param name="PageIndex">页码</param>
		/// <param name="PageSize">页数</param>
        /// <returns>WTB_YIHUDRKXX信息</returns>
		public DataTable SelectWTB_YIHUDRKXXesDynamic(string WhereClause, string OrderByExpression, int PageIndex,int PageSize)
        {
            return SelectWTB_YIHUDRKXXesDynamic(WhereClause, OrderByExpression,PageIndex,PageSize,null);
        }		
		
		/// <summary>
		///根据条件更新WTB_YIHUDRKXX字段
		/// </summary>
		/// <returns>受影响行数</returns>
		public int UpdateWTB_YIHUDRKXXesDynamic(string UpdateValue,string WhereClause,OracleTransaction Transaction)
		{
			int result = 0;
			if(UpdateValue == "" || WhereClause == "")
			{
				return 0;	
			}
			string spName = "CS_UpdWTB_YIHUDRKXXDyn";
			OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
			DataSet ds=null;
			storedParams[0].Value = UpdateValue;
            storedParams[1].Value = WhereClause;
			if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName,storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName,storedParams);
			result = Convert.ToInt32(storedParams[2].Value);
			return result;
		}
		
		/// <summary>
		///根据条件更新WTB_YIHUDRKXX字段
		/// </summary>
		/// <returns>受影响行数</returns>
		public int UpdateWTB_YIHUDRKXXesDynamic(string UpdateValue,string WhereClause)
		{
			return UpdateWTB_YIHUDRKXXesDynamic(UpdateValue,WhereClause,null);
		}
		
		
		#endregion
		#region Private
		
		private int InsertWTB_YIHUDRKXX(WTB_YIHUDRKXX WTB_YIHUDRKXX,OracleTransaction Transaction)
		{
            string spName = "CS_InsWTB_YIHUDRKXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
			storedParams[0].Value = WTB_YIHUDRKXX.S_ZHUBIAOBH;
			storedParams[1].Value = WTB_YIHUDRKXX.INCIDENT_ID;
			storedParams[2].Value = WTB_YIHUDRKXX.CONTACT_NUM;
			storedParams[3].Value = WTB_YIHUDRKXX.REQ_TYPE;
			storedParams[4].Value = WTB_YIHUDRKXX.COMPANY;
			storedParams[5].Value = WTB_YIHUDRKXX.SETTLE_METHOD;
			storedParams[6].Value = WTB_YIHUDRKXX.YWYHDZ;
			storedParams[7].Value = WTB_YIHUDRKXX.INCLUDE_APPLICANT;
			storedParams[8].Value = WTB_YIHUDRKXX.PEOPLE_NUM;
			storedParams[9].Value = WTB_YIHUDRKXX.OPER_TYPE;
			storedParams[10].Value = WTB_YIHUDRKXX.EMAIL;
			storedParams[11].Value = WTB_YIHUDRKXX.APP_TYPE;
			storedParams[12].Value = WTB_YIHUDRKXX.ADDRESS_CHECK;
            int result=0;
            if (Transaction == null)
                result=OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result=OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
			WTB_YIHUDRKXX.ID=Convert.ToInt32(storedParams[13].Value);
            return result;
        }
		private bool UpdateWTB_YIHUDRKXX(WTB_YIHUDRKXX WTB_YIHUDRKXX,OracleTransaction Transaction)
        {
            string spName = "CS_UpdWTB_YIHUDRKXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
			storedParams[0].Value = WTB_YIHUDRKXX.S_ZHUBIAOBH;
			storedParams[1].Value = WTB_YIHUDRKXX.INCIDENT_ID;
			storedParams[2].Value = WTB_YIHUDRKXX.CONTACT_NUM;
			storedParams[3].Value = WTB_YIHUDRKXX.REQ_TYPE;
			storedParams[4].Value = WTB_YIHUDRKXX.COMPANY;
			storedParams[5].Value = WTB_YIHUDRKXX.SETTLE_METHOD;
			storedParams[6].Value = WTB_YIHUDRKXX.YWYHDZ;
			storedParams[7].Value = WTB_YIHUDRKXX.INCLUDE_APPLICANT;
			storedParams[8].Value = WTB_YIHUDRKXX.PEOPLE_NUM;
			storedParams[9].Value = WTB_YIHUDRKXX.OPER_TYPE;
			storedParams[10].Value = WTB_YIHUDRKXX.EMAIL;
			storedParams[11].Value = WTB_YIHUDRKXX.APP_TYPE;
			storedParams[12].Value = WTB_YIHUDRKXX.ADDRESS_CHECK;
			storedParams[13].Value = WTB_YIHUDRKXX.ID;
			int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;            
        }
		
		
		private WTB_YIHUDRKXX PopulateWTB_YIHUDRKXX(IDataReader dr)
        {
			WTB_YIHUDRKXX WTB_YIHUDRKXX=new WTB_YIHUDRKXX();
				WTB_YIHUDRKXX.ID = Convert.ToInt32(dr["ID"].ToString());
			WTB_YIHUDRKXX.S_ZHUBIAOBH=dr["S_ZHUBIAOBH"] == DBNull.Value ? null : (string)dr["S_ZHUBIAOBH"];
			WTB_YIHUDRKXX.INCIDENT_ID=dr["INCIDENT_ID"] == DBNull.Value ? null : (string)dr["INCIDENT_ID"];
			WTB_YIHUDRKXX.CONTACT_NUM=dr["CONTACT_NUM"] == DBNull.Value ? null : (string)dr["CONTACT_NUM"];
			WTB_YIHUDRKXX.REQ_TYPE=dr["REQ_TYPE"] == DBNull.Value ? null : (string)dr["REQ_TYPE"];
			WTB_YIHUDRKXX.COMPANY=dr["COMPANY"] == DBNull.Value ? null : (string)dr["COMPANY"];
			WTB_YIHUDRKXX.SETTLE_METHOD=dr["SETTLE_METHOD"] == DBNull.Value ? null : (string)dr["SETTLE_METHOD"];
			WTB_YIHUDRKXX.YWYHDZ=dr["YWYHDZ"] == DBNull.Value ? null : (string)dr["YWYHDZ"];
			WTB_YIHUDRKXX.INCLUDE_APPLICANT=dr["INCLUDE_APPLICANT"] == DBNull.Value ? null : (string)dr["INCLUDE_APPLICANT"];
			WTB_YIHUDRKXX.PEOPLE_NUM=dr["PEOPLE_NUM"] == DBNull.Value ? null : (string)dr["PEOPLE_NUM"];
			WTB_YIHUDRKXX.OPER_TYPE=dr["OPER_TYPE"] == DBNull.Value ? null : (string)dr["OPER_TYPE"];
			WTB_YIHUDRKXX.EMAIL=dr["EMAIL"] == DBNull.Value ? null : (string)dr["EMAIL"];
			WTB_YIHUDRKXX.APP_TYPE=dr["APP_TYPE"] == DBNull.Value ? null : (string)dr["APP_TYPE"];
			WTB_YIHUDRKXX.ADDRESS_CHECK=dr["ADDRESS_CHECK"] == DBNull.Value ? null : (string)dr["ADDRESS_CHECK"];
			return WTB_YIHUDRKXX;
        }
		
		
		private void AddRowNumber(DataTable dt)
		{
			dt.Columns.Add(new DataColumn("RowNumber",typeof(int)));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i][dt.Columns.Count - 1] = i + 1;
            }
		}
		#endregion
    }
}
#endregion